package com.power.sifa.approve.api;

import com.plf.common.domain.ResponseDTO;
import com.plf.common.exception.BusinessException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

public interface IBusinessApprove {

    /**
     * 启动一个业务子流程
     * @param applyid 申请id
     * @param proctype 操作分类
     * @param userid 用户id
     * @param username 用户username
     * @param processinstanceid
     * @param cause 案由
     * @param describe 行政复议申请
     * @param docfield 表单上的文书字段
     * @throws BusinessException
     */
    @PostMapping("/businessapprove/startBusinessProced")
    ResponseDTO startBusinessProced(
            @RequestParam String applyid,
            @RequestParam String proctype,
            @RequestParam String userid,
            @RequestParam String username,
            @RequestParam String processinstanceid,
            @RequestParam(required = false) String cause,
            @RequestParam(required = false) String describe,
            @RequestBody Map<String, Object> docfield);

    /**
     * 查询工作日的截止日期
     * @param applyid
     * @param days
     * @return
     */
    @PostMapping("/businessapprove/weekdayDeadline")
    ResponseDTO weekdayDeadline(String applyid,Integer days);

    /**
     * 在线预览doc文件
     * @param request
     * @param response
     * @param applyid
     * @param proctype
     * @param docfield
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/previewDecisionDoc")
    ResponseDTO previewDecisionDoc(HttpServletRequest request, HttpServletResponse response,
                            @RequestParam String applyid, @RequestParam  String proctype,
                            @RequestBody Map<String, Object> docfield) throws Exception;

    /**
     * 预览审批文书
     * @param applyid
     * @return
     */
    @PostMapping("/businessapprove/previewApproveDoc")
    ResponseDTO previewApproveDoc(@RequestParam String applyid, @RequestParam String modelKey, @RequestBody Map<String, Object> formData) throws Exception;


    /**
     * 通过文件名匹配文件生成文件流返回预览
     * @param request
     * @param response
     * @param applyid
     * @param materilaType
     * @param docfield
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/previewDocByDocName")
    ResponseDTO previewDocByDocName(HttpServletRequest request, HttpServletResponse response,
                                  @RequestParam String applyid, @RequestParam Integer materilaType,
                                  @RequestBody Map<String, Object> docfield) throws Exception;


    /**
     * 通过文件名匹配文件生成pdf流返回保存
     * @param request
     * @param response
     * @param applyid
     * @param materilaType
     * @param docfield
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/savePreviewDocPdfByDocName")
    ResponseDTO savePreviewDocPdfByDocName(HttpServletRequest request, HttpServletResponse response,
                                    @RequestParam String applyid, @RequestParam Integer materilaType,
                                    @RequestBody Map<String, Object> docfield) throws Exception;

    /**
     * 初始化获取对应的文件参数
     * @param applyid
     * @param materilaType
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/initPreviewDocParam")
    ResponseDTO initPreviewDocParam(@RequestParam String applyid, @RequestParam Integer materilaType) throws Exception;

    /**
     * 预览文件进行保存
     * @param applyid
     * @param materilaType
     * @param busiType
     * @param userId
     * @param userName
     * @param docfield
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/savePreviewDocByMaterial")
    ResponseDTO savePreviewDocByMaterial(@RequestParam String applyid, @RequestParam Integer materilaType,
                                        @RequestParam Integer busiType, @RequestParam String userId,
                                        @RequestParam String userName, @RequestBody Map<String, Object> docfield) throws Exception;


    /**
     * 对应的表单绑定材料更新
     * @param optionid
     * @param userId
     * @param userName
     * @param docfield
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/updatePreviewDocByMaterial")
    ResponseDTO updatePreviewDocByMaterial(@RequestParam String optionid, @RequestParam String userId,
                                         @RequestParam String userName, @RequestBody Map<String, Object> docfield) throws Exception;


    /**
     *
     * 盖章材料测试 (临时)
     * @param applyid
     * @param proctype
     * @return
     */
    @PostMapping("/businessapprove/templateStamp")
    ResponseDTO  templateStamp(String applyid, Integer proctype);

    /**
     * 盖章材料格式转换 (临时)
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/transSignMaterial")
    ResponseDTO transSignMaterial();

    /**
     * 事件执行触发 (临时)
     * @return
     * @throws Exception
     */
    @PostMapping("/businessapprove/triggerExecute")
    ResponseDTO triggerExecute();


    /**
     * 变更流程中的决定类型
     * @param f_applyid
     * @param applyid
     * @param decisiontype
     * @param decisiontypeid
     * @param decisiontypename
     * @return
     */
    @PostMapping("/businessapprove/changeDecisionType")
    ResponseDTO changeDecisionType(String f_applyid, String applyid,Integer decisiontype, Integer decisiontypeid, String decisiontypename);


}
